//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************

//**********************************************************************
// $Header: /Alaska/Tools/template.c 6     1/13/10 2:13p Felixp $
//
// $Revision: 6 $
//
// $Date: 1/13/10 2:13p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/Tools/template.c $
// 
// 6     1/13/10 2:13p Felixp
// 
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:  <This File's Name>
//
// Description:	
//
//<AMI_FHDR_END>
//**********************************************************************

#include <AmiDxeLib.h>
#include <Token.h>
#include <Include/Protocol/SmmSwDispatch2.h>
#include <OemDxeLib\OemDxeLib.h>


EFI_STATUS SmmSwdisPlay (
    IN EFI_HANDLE                   DispatchHandle,
    IN CONST VOID                   *DispatchContext OPTIONAL,
    IN OUT VOID                     *CommBuffer OPTIONAL,
    IN OUT UINTN                    *CommBufferSize OPTIONAL )
{
// WRITE A VALUE TO CMOS BY SMM IN 0xb2;
	CmosDxeWrite(SW_SMI_Value,SW_SMI_Value);
    return EFI_SUCCESS;
}

EFI_STATUS OemSmmFunction(
	IN EFI_HANDLE                   ImageHandle,
	IN EFI_SYSTEM_TABLE             *SystemTable
)
{
    EFI_STATUS                      Status=EFI_SUCCESS;
    EFI_HANDLE                      OemHandle=NULL;
    EFI_SMM_SW_DISPATCH2_PROTOCOL   *OemDispatch = NULL;
    EFI_SMM_SW_REGISTER_CONTEXT     OemContext ;
    
    Status = pSmst->SmmLocateProtocol(&gEfiSmmSwDispatch2ProtocolGuid, 
                                       NULL, 
                                       &OemDispatch);

    OemContext.SwSmiInputValue = SW_SMI_Value;
    Status = OemDispatch->Register(OemDispatch,
                                   SmmSwdisPlay,
                                   &OemContext,
                                   &OemHandle);

        return EFI_SUCCESS;
}

EFI_STATUS EFIAPI InitOemSmi(
    IN EFI_HANDLE           ImageHandle,
    IN EFI_SYSTEM_TABLE     *SystemTable )
{

    InitAmiLib(ImageHandle, SystemTable);
    return InitSmmHandler(ImageHandle, SystemTable, OemSmmFunction, NULL);

}

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
